const generateRandomToken = (length = 32) => {
  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
  let result = '';
  for (let i = 0; i < length; i++) {
    result += characters.charAt(Math.floor(Math.random() * characters.length));
  }
  return result;
};

export default [
  // 用户登录接口
  {
    url: '/api/user/login',
    method: 'post',
    response: () => {
      // 如果有返回成功信息
      return {
        code: 200,
        msg: '请求成功',
        data: {
          expires: 1800,
          token: generateRandomToken()
        }
      };
    }
  },
  // 用户信息接口
  {
    url: '/api/user/userInfo',
    method: 'get',
    response: () => {
      // 如果有返回成功信息
      return {
        code: 200,
        msg: '请求成功',
        data: {
          userId: 2,
          avatar: 'https://wx3.sinaimg.cn/mw690/006YekfUgy1hrefyotmx3j30dw0dwdgi.jpg',
          username: 'ROOT',
          nickname: '超级管理员',
          password: '123456',
          desc: 'vite-plugin-mock确实有点方便',
          roles: ['ROOT'],
          perms: ['cuser.detail', 'cuser.user']
        }
      };
    }
  },
  // 登出接口 注销
  {
    url: '/api/user/logout',
    method: 'post',
    response: () => {
      // 如果有返回成功信息
      return {
        code: 200,
        msg: '请求成功',
        data: null
      };
    }
  }
];
